using System;
using System.Collections.Generic;
using System.Text;

namespace SharePointSearchBench.Library.Logging
{
    /// <summary>
    /// Used for writing fatal error messages to a log.  Provides method start/end
    /// information and can be disposed.
    /// </summary>
    public class DisposableFatalLogWriter : IDisposableLogWriter
    {
        /// <summary>
        /// Creates a new instance of the class.
        /// </summary>
        public DisposableFatalLogWriter()
        {
            FatalLogWriter.WriteMessageInternal("");           
        }

        /// <summary>
        /// Creates a new instance of the class.  
        /// </summary>
        /// <param name="message"></param>
        public DisposableFatalLogWriter(string message)
        {
            FatalLogWriter.WriteMessageInternal(string.Format("BEGIN: {0}", message));
        }

        /// <summary>
        /// Writes a fatal message to a log.
        /// </summary>
        /// <param name="message"></param>
        public void WriteMessage(string message)
        {
            FatalLogWriter.WriteMessageInternal(message);
        }

        /// <summary>
        /// Disposes the object.
        /// </summary>
        public void Dispose()
        {
            FatalLogWriter.WriteMessageInternal("END");
        }
    }
}
